import java.util.ArrayList;
import java.util.List;

public class Solution559 {
    static class Node {
        public int val;
        public List<Node> children;

        public Node() {}

        public Node(int _val) {
            val = _val;
        }

        public Node(int _val, List<Node> _children) {
            val = _val;
            children = _children;
        }
    };

    public int maxDepth(Node root) {
        if (root==null){
            return 0;
        }
        if (root.children==null){
            return 1;
        }
        int ans=0;
        for (Node child : root.children) {
            ans=Math.max(maxDepth(child),ans);
        }
        return ans+1;
    }

    public static void main(String[] args) {
        Node n5=new Node(5,null);
        Node n6=new Node(6,null);
        List<Node> list1=new ArrayList<>();
        list1.add(n5);
        list1.add(n6);
        Node node3=new Node(3,list1);
        Node node2=new Node(2,null);
        Node node4=new Node(4,null);
        List<Node> list2=new ArrayList<>();
        list2.add(node3);
        list2.add(node2);
        list2.add(node4);
        Node node1=new Node(1,list2);
        System.out.println(new Solution559().maxDepth(node1));
    }
}
